package chan.project.smartlawmodel.vo;

import chan.project.smartlawmodel.entity.LawRegulation;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 法律法规信息视图
 *
 * @author <a href="https://github.com/kavansp">kavansp</a>
 * @from <a href="https://www.code-nav.cn">编程导航学习圈</a>
 */
@Data
public class LawRegulationVO implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 标题
     */
    private String title;

    /**
     * 内容
     */
    private String content;

    /**
     * 创建用户 id
     */
    private Long userId;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    /**
     * 标签列表
     */
    private List<String> tagList;

    /**
     * 创建用户信息
     */
    private UserInfoVO user;

    /**
     * 封装类转对象
     *
     * @param LawRegulationVO
     * @return
     */
    public static LawRegulation voToObj(LawRegulationVO LawRegulationVO) {
        if (LawRegulationVO == null) {
            return null;
        }
        LawRegulation LawRegulation = new LawRegulation();
        BeanUtils.copyProperties(LawRegulationVO, LawRegulation);
        return LawRegulation;
    }

    /**
     * 对象转封装类
     *
     * @param LawRegulation
     * @return
     */
    public static LawRegulationVO objToVo(LawRegulation LawRegulation) {
        if (LawRegulation == null) {
            return null;
        }
        LawRegulationVO LawRegulationVO = new LawRegulationVO();
        BeanUtils.copyProperties(LawRegulation, LawRegulationVO);
        return LawRegulationVO;
    }

    /**
     * 获取封装类列表
     * @param LawRegulationList
     * @return
     */
    public static List<LawRegulationVO> objListToVoList(List<LawRegulation> LawRegulationList) {
        if (LawRegulationList == null) {
            return null;
        }
        return LawRegulationList.stream().map(LawRegulationVO::objToVo).collect(Collectors.toList());
    }
}
